<style>
	.amap-wrapper {
		width: 900px;
		height: 600px;
	}
	
	.amap-demo {
		height: 100px;
	}
</style>
<template>
	<div style="margin-left: 10px;margin-top: 20px;">
			<Row>
				<Col span="16">
				<Form ref="formData" :model="formData" label-position="left" :label-width="100">
					
					<FormItem label="取消订单设置" prop="set_order_canel_time">
						<Input v-model="formData.set_order_canel_time" >
						 <span slot="prepend">订单开始：</span>
        				 <span slot="append">分钟后不得取消订单</span>
        				</Input>
					</FormItem>

					<FormItem label="" prop="set_order_canel_price">
						<Input v-model="formData.set_order_canel_price" >
						 <span slot="prepend">订单取消价格：</span>
        				 <span slot="append">元</span>
        				</Input>
					</FormItem>
					

					<FormItem label="送车上门价格" prop="set_sm_price">
						<Input v-model="formData.set_sm_price">
						<span slot="append">元/公里</span>
						</Input>
					</FormItem>

					<FormItem label="担保费用" prop="set_db_price">
						<Input v-model="formData.set_db_price">
						<span slot="append">元</span>
						</Input>
					</FormItem>

				</Form>
				</Col>
			</Row>

			<div slot="footer">
				<Button type="primary" @click="edit" :loading='saveLoading'>确认修改 </Button>
			</div>

	</div>
</template>
<script>
	import {
		getInfo,
		editRule,
	} from '@/api/rule'

	//import Editor from '_c/editor'
	//import Upload from '_c/common/upload'
	export default {
		components: {
			//  Editor,
			//  Upload
		},
		props: {
			modalId: {
				type: Number,
				default: 0
			}
		},
		created() {
			let t = this;
				this.getInfoById()
		},
		data() {
			let t = this;
			return {
				saveLoading: false,
				formData: {
					set_order_canel_time:'',
					set_order_canel_price: '',
					set_sm_price: '',
					set_db_price: '',
				}
			}
		},
		methods: {
			getInfoById() {
				let t = this
				getInfo().then(res => {
					if(res.data.code == 1){
						let res_data = res.data.data;
						//console.log(res_data);
					    t.formData =  {
					    	set_order_canel_time:res_data.set_order_canel_time,
							set_order_canel_price:res_data.set_order_canel_price,
							set_sm_price:res_data.set_sm_price,
							set_db_price:res_data.set_db_price,
						}
					    
					
					}else{
						t.$Notice.error({
							title: res.data.msg
						})
						this.$emit('on-edit-modal-hide')
						this.modalShow = false
					}
					
				})

			},
			edit() {
				let t = this
				t.$refs.formData.validate((valid) => {
					if(valid) {
						t.saveLoading = true
						//console.log(JSON.stringify(t.formData));
						editRule(t.formData).then(res => {
							if(res.data.code == 1) {
								t.saveLoading = false
								t.modalShow = false
								t.$emit('on-edit-modal-success')
								t.$emit('on-edit-modal-hide')
								t.$Notice.success({
									title: res.data.msg
								})
								t.getInfoById();
							} else {
								t.saveLoading = false
								t.$Notice.error({
									title: res.data.msg
								})
							}

						}, function(error) {
							t.saveLoading = false
						})
					}
				})
			},
			cancel() {
				this.$emit('on-edit-modal-hide')
				this.modalShow = false
			}
		},

	}
</script>